<!--
 * @Author: 余铖
 * @Date: 2020-03-30 08:02:56
 * @LastEditors: 余铖
 * @LastEditTime: 2020-04-01 15:35:35
 * @Description: 问卷基本信息-模态框
 -->
<template>

	<Modal v-model="modal1" :title="title" @on-ok="ok" @on-cancel="cancel">
		<Form ref="Dialog" :model="formItem" :label-width="80">
			<FormItem label="问卷名称">
				<Input v-model="formItem.examName" placeholder="请输入调查名称"></Input>
			</FormItem>
			<FormItem label="问卷类型">
				<Select v-model="formItem.examType">
					<Option value="DW">单位问卷</Option>
					<Option value="YB">一般问卷</Option>
					<Option value="GZ">工作问卷</Option>
				</Select>
			</FormItem>
			<FormItem label="问卷选项">
				<Input v-model="formItem.examOption" placeholder="请输入问卷选项的值"></Input>
			</FormItem>
			<FormItem label="问卷权重">
				<Input type="number" v-model="formItem.examWeight" placeholder="请输入调查名称"></Input>
			</FormItem>
		</Form>
	</Modal>
</template>

<script>
import { requestData } from "@/api/personal.js";

export default {
	//import引入的组件需要注入到对象中才能使用
	components: {},
	data() {
		//这里存放数据
		return {
            modal1: false,
            title: '',
			formItem: {
				optionType: "add",
				inquireName: "",
				inquireSource: ""
			}
		};
	},
	//监听属性 类似于data概念
	computed: {},
	//监控data中的数据变化
	watch: {},
	//方法集合
	methods: {
		ok() {
			requestData({
				formData: { quesFilter: this.formItem },
				url: "/exam/User/questionnaire"
			})
				.then(result => {
					console.log(result, "resultresultresult");
                    this.tabelLoading = false;
					if (result.data.code === "200") {
                        this.$emit('OK');
                        this.resetForm();
                        this.$Message.success(result.data.message);
					} else {
						this.$Message.error("失败");
                    }
				})
				.catch(err => {
					console.log(err);
				});
        },
		cancel() {
			// this.$Message.info("Clicked cancel");
        },
        resetForm() {
            this.formItem = {
                optionType: "add",
                inquireName: "",
                inquireSource: ""
            }
        }
	},
	//生命周期 - 创建完成（可以访问当前this实例）
	created() {},
	//生命周期 - 挂载完成（可以访问DOM元素）
	mounted() {}
};
</script>
<style>
</style>